x86/mm: Improve ring management for memory events. Do not lose guest events
authorAndres Lagar-Cavilla <andres@lagarcavilla.org>
Thu, 19 Jan 2012 10:38:47 +0000 (10:38 +0000)
committerAndres Lagar-Cavilla <andres@lagarcavilla.org>
Thu, 19 Jan 2012 10:38:47 +0000 (10:38 +0000)
commit3643a961195f76ba849a213628c1979240e6fbdd
treef52a9b0fd47756a1ddd35ec1493fd6271ddf60fd
parenta6ec974704c7ed6a48ca75957655a79cb9a55a7f
x86/mm: Improve ring management for memory events. Do not lose guest events

This patch is an amalgamation of the work done by Olaf Hering <olaf@aepfle.de>
and our work.

It combines logic changes to simplify the memory event API, as well as
leveraging wait queues to deal with extreme conditions in which too many
events are generated by a guest vcpu.

In order to generate a new event, a slot in the ring is claimed. If a
guest vcpu is generating the event and there is no space, it is put on a
wait queue. If a foreign vcpu is generating the event and there is no
space, the vcpu is expected to retry its operation. If an error happens
later, the function returns the claimed slot via a cancel operation.

Thus, the API has only four calls: claim slot, cancel claimed slot, put
request in the ring, consume the response.

With all these mechanisms, no guest events are lost.
Our testing includes 1. ballooning down 512 MiBs; 2. using mem access n2rwx, in
which every page access in a four-vCPU guest results in an event, with no vCPU
pausing, and the four vCPUs touching all RAM. No guest events were lost in
either case, and qemu-dm had no mapping problems.

Signed-off-by: Adin Scannell <adin@scannell.ca>
Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
xen/arch/x86/hvm/hvm.c
xen/arch/x86/mm/mem_event.c
xen/arch/x86/mm/mem_sharing.c
xen/arch/x86/mm/p2m.c
xen/include/asm-x86/mem_event.h
xen/include/xen/mm.h
xen/include/xen/sched.h